﻿cd /d %~dp0
pip install esptool -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install adafruit-ampy -i https://pypi.tuna.tsinghua.edu.cn/simple

set SPORT=com10

esptool.exe --port %SPORT% -b 115200 erase_flash || esptool.py --port %SPORT% -b 115200 erase_flash
esptool.exe --chip esp8266 --port %SPORT% --baud 115200 write_flash --flash_size=detect 0 esp8266-1m-20220117-v1.18.bin || esptool.py --chip esp8266 --port %SPORT% --baud 115200 write_flash --flash_size=detect 0 esp8266-1m-20220117-v1.18.bin


ampy --port %SPORT% -b 115200 put ./code/__download.py
ampy --port %SPORT% -b 115200 put ./code/__upload.py

ampy --port %SPORT% -b 115200 put ./code/touchtool.mpy
ampy --port %SPORT% -b 115200 put ./code/config_main.html
ampy --port %SPORT% -b 115200 put ./code/t16_config.html
ampy --port %SPORT% -b 115200 put ./code/t16_default.cfg
ampy --port %SPORT% -b 115200 put ./code/favicon.ico

ampy --port %SPORT% -b 115200 put ./code/wifi.txt
ampy --port %SPORT% -b 115200 put ./code/main.py

TIMEOUT -T 1

esptool.exe --port %SPORT% run || esptool.py --port %SPORT% run

pause